package com.xiaolin.storage.controller;

import com.xiaolin.storage.service.StorageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author xiaolin
 * @description 仓库服务
 * @since 2024/5/23
 */
@RestController
@RequestMapping("/storage")
@RefreshScope // nacos配置更新时，自动更新配置的值
public class StorageController {
    @Autowired
    private StorageService storageService;

    @Value("${flag}")
    private String flag;

    @GetMapping("/reduceStorage/{productId}")
    public String reduceStorage(@PathVariable Integer productId) {
        System.out.println("标记：" + flag);
        return storageService.reduceStorage(productId);
    }
}
